home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 25
/
Aminet 25 (1998)(GTI - Schatztruhe)[!][Jun 1998].iso
/
Aminet
/
util
/
pack
/
xpk_Source.lha
/
xpk_Source
/
xpkmaster
/
xbuf.c
< prev
next >
Wrap
C/C++ Source or Header
|
1998-03-26
|
2KB
|
67 lines
#ifndef XPKMASTER_XBUF_C
#define XPKMASTER_XBUF_C
/* Routinesheader
Name: xbuf.c
Main: xpkmaster
Versionstring: $VER: xbuf.c 1.2 (09.01.1998)
Author: SDI
Distribution: Freeware
Description: Xpk buffer handling
1.0 09.10.96 : first real version
1.1 31.02.97 : now free's password buffer
1.2 09.09.98 : added XPK_ALLINONE
*/
#include <proto/exec.h>
#include <exec/memory.h>
#include <exec/libraries.h>
#include <dos/dos.h>
#include "xpkmaster.h"
/************************* alloc and init xbuf ***************************/
XPK_ALLINONE struct XpkBuffer *initxbuf(void)
{
struct XpkBuffer *xbuf;
if(!(xbuf = (struct XpkBuffer *) AllocMem(sizeof(struct XpkBuffer),
MEMF_CLEAR)))
return 0;
/* Save the original task priority in case we change it during an
operation */
xbuf->xb_Priority = FindTask(0L)->tc_Node.ln_Pri;
xbuf->xb_InLen = -1;
return xbuf;
}
/***************************** free bufs *******************************/
XPK_ALLINONE LONG freebufs(struct XpkBuffer *xbuf)
{ /* Free an XpkBuffer */
LONG error = xbuf->xb_Result;
if(xbuf->xb_xfd)
{
struct xfdMasterBase *xfdMasterBase = (struct xfdMasterBase *) xbuf->xb_SubBase;
xfdFreeObject(xbuf->xb_xfd);
}
closesub(xbuf); /* Free any open sub-library */
if(xbuf->xb_Flags & XMF_OWNTASKPRI)
SetTaskPri(FindTask (NULL), xbuf->xb_Priority);
if(xbuf->xb_Flags & XMF_OWNPASSWORD)
FreeMem(xbuf->xb_Password, xbuf->xb_PasswordSize);
FreeMem(xbuf, sizeof(struct XpkBuffer));
/* Finally, free the handle itself */
return error;
}
#endif /* XPKMASTER_XBUF_C */